//
//  gbFootView.m
//  10-团购
//
//  Created by wangneihan on 15/12/19.
//  Copyright © 2015年 wangneihan. All rights reserved.
//

#import "gbFootView.h"

@interface gbFootView()

@property (weak, nonatomic) IBOutlet UIButton *loadMoreBtn;

@property (weak, nonatomic) IBOutlet UIView *loadingView;

@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *actView;

-(IBAction)loadMoreBtnClicked;

@end

@implementation gbFootView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

+(gbFootView *)loadGbFootView
{
    gbFootView *footView = [[[NSBundle mainBundle]loadNibNamed:@"gbFootView" owner:nil options:nil]lastObject];
    footView.loadMoreBtn.layer.cornerRadius = 5;
    footView.loadMoreBtn.layer.masksToBounds = YES;
    [footView.loadMoreBtn addTarget:0 action:@selector(loadMoreBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    return footView;
}

-(IBAction)loadMoreBtnClicked{
    
    self.loadMoreBtn.hidden = YES;
    self.loadingView.hidden = NO;
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        self.loadMoreBtn.hidden = NO;
        self.loadingView.hidden = YES;
        
        //3 向代理对象发送消息
        if([self.delegate respondsToSelector:@selector(gbfootViewDidClickedLoadMore:)])
        {
            [self.delegate gbfootViewDidClickedLoadMore:self];
        }
    });
    
    
}

@end
